﻿using Microsoft.Practices.Prism.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using WebServerConnectorDll;

namespace WebServerConnectorDll
{
    [DataContract]
    public class CPersonnel : NotificationObject, IFruitClass
    {
        private bool    isChoose;
        private int     uid;
        private String  name;
        private String  username;
        private String  password;
        private String  image;
        private int     personnelGroupUID;
        private String  personnelGroupName;
        private int     sex;
        private String  sexName;
        private String  id;
        private String  birthday;
        private String  phone;
        private String  emergency;
        private int     cityUID;
        private String  cityName;
        private int     provinceUID;
        private String  provinceName;
        private String  webChat;
        private String  createTime;

        public bool IsChoose
        {
            get
            {
                return isChoose;
            }
            set
            {
                isChoose = value;
                RaisePropertyChanged("IsChoose");
            }
        }

        [DataMember(Order = 0)]
        public int UID
        {
            get
            {
                return uid;
            }
            set
            {
                uid = value;
                RaisePropertyChanged("UID");
            }
        }

        [DataMember(Order = 1)]
        public String Name
        {
            get
            {
                return name;
            }
            set
            {
                name = value;
                RaisePropertyChanged("Name");
            }
        }

        [DataMember(Order = 2)]
        public String Username
        {
            get
            {
                return username;
            }
            set
            {
                username = value;
                RaisePropertyChanged("Username");
            }
        }

        [DataMember(Order = 3)]
        public String Password
        {
            get
            {
                return password;
            }
            set
            {
                password = value;
                RaisePropertyChanged("Password");
            }
        }

        [DataMember(Order = 4)]
        public String Image
        {
            get
            {
                return image;
            }
            set
            {
                image = value;
                RaisePropertyChanged("Image");
            }
        }

        [DataMember(Order = 5)]
        public int PersonnelGroupUID
        {
            get
            {
                return personnelGroupUID;
            }
            set
            {
                personnelGroupUID = value;
                RaisePropertyChanged("PersonnelGroupUID");
            }
        }

        [DataMember(Order = 6)]
        public String PersonnelGroupName
        {
            get
            {
                return personnelGroupName;
            }
            set
            {
                personnelGroupName = value;
                RaisePropertyChanged("PersonnelGroupName");
            }
        }

        [DataMember(Order = 7)]
        public int Sex
        {
            get
            {
                return sex;
            }
            set
            {
                if(value == 0)
                {
                    SexName = "男";
                }
                else
                {
                    SexName = "女";
                }
                sex = value;
                RaisePropertyChanged("Sex");
            }
        }

        [DataMember(Order = 7)]
        public String SexName
        {
            get
            {
                return sexName;
            }
            set
            {
                sexName = value;
                RaisePropertyChanged("SexName");
            }
        }

        [DataMember(Order = 8)]
        public String ID
        {
            get
            {
                return id;
            }
            set
            {
                id = value;
                RaisePropertyChanged("ID");
            }
        }

        [DataMember(Order = 9)]
        public String Birthday
        {
            get
            {
                return birthday;
            }
            set
            {
                birthday = value;
                RaisePropertyChanged("Birthday");
            }
        }

        [DataMember(Order = 10)]
        public String Phone
        {
            get
            {
                return phone;
            }
            set
            {
                phone = value;
                RaisePropertyChanged("Phone");
            }
        }

        [DataMember(Order = 11)]
        public String Emergency
        {
            get
            {
                return emergency;
            }
            set
            {
                emergency = value;
                RaisePropertyChanged("Emergency");
            }
        }

        [DataMember(Order = 12)]
        public int CityUID
        {
            get
            {
                return cityUID;
            }
            set
            {
                cityUID = value;
                RaisePropertyChanged("CityUID");
            }
        }

        [DataMember(Order = 13)]
        public String CityName
        {
            get
            {
                return cityName;
            }
            set
            {
                cityName = value;
                RaisePropertyChanged("CityName");
            }
        }

        [DataMember(Order = 14)]
        public int ProvinceUID
        {
            get
            {
                return provinceUID;
            }
            set
            {
                provinceUID = value;
                RaisePropertyChanged("ProvinceUID");
            }
        }

        [DataMember(Order = 15)]
        public String ProvinceName
        {
            get
            {
                return provinceName;
            }
            set
            {
                provinceName = value;
                RaisePropertyChanged("ProvinceName");
            }
        }

        [DataMember(Order = 16)]
        public String WebChat
        {
            get
            {
                return webChat;
            }
            set
            {
                webChat = value;
                RaisePropertyChanged("WebChat");
            }
        }

        [DataMember(Order = 17)]
        public String CreateTime
        {
            get
            {
                return createTime;
            }
            set
            {
                createTime = value;
                RaisePropertyChanged("CreateTime");
            }
        }

        public CPersonnel(String pName, String pUsername, String pPassword, String pImage, int pPersonnelGroupUID, int pSex, String pID, String pBirthday, String pPhone, String pEmergency, int pCityUID, String pWebChat)
        {
            Name = pName;
            Username = pUsername;
            Password = pPassword;
            Image = pImage;
            PersonnelGroupUID = pPersonnelGroupUID;
            Sex = pSex;
            ID = pID;
            Birthday = pBirthday;
            Phone = pPhone;
            Emergency = pEmergency;
            CityUID = pCityUID;
            WebChat = pWebChat;
        }

        public String ToInsertString()
        {
            return "\'" + Name + "\'-\'" + Username + "\'-\'" + Password + "\'-\'" + Image + "\'-" + PersonnelGroupUID + "-" + Sex + "-\'" + ID + "\'-\'" + Birthday + "\'-" + Phone + "-" + Emergency + "-" + CityUID + "-\'" + WebChat + "\'";
        }

        public String ToUpdateString()
        {
            return "Name=\'" + Name + "\',Username=\'" + Username + "\',Password=\'" + Password + "\',Image=\'" + Image + "\',PersonnelGroupUID=" + PersonnelGroupUID + ",Sex=" + Sex + ",ID=\'" + ID + "\',Birthday=\'" + Birthday + "\',Phone=" + Phone + ",Emergency=" + Emergency + ",CityUID=" + CityUID + ",WebChat=\'" + WebChat + "\'";
        }
    }
}